import React, { Component } from 'react'

export default class MealCate extends Component {
   
    
    render() {
      
        return (
            <div className="category"> 
        
                {this.props.meal_list.map((v,i)=>{
                    return <span  className={ this.props.meal_selected_cate_index+''===i+''?"item active":"item"}  data-index={i} data-cate={v.cate} key={i}  onClick={(e)=>{
                     
                      this.props.selectCate({
                         meal_selected_cate:e.target.getAttribute('data-cate'),
                         meal_selected_cate_index:e.target.getAttribute('data-index'),
                      })

                      // 滚动到指定的位置， 传递 x轴和y轴的位置，y轴的位置通过getTopPoistion方法获取
                      document.documentElement.scrollTo(0,this.props.getTopPoistion(i,this.props.meal_position_arr));
                    }}>{v.cate}</span>  
                })}
            </div>
        )
    }
}
